(function($) {
	$.fn.vp2_html5_rightSidePlaylist_Video = function(options) {
		//fullscreen vars
		var bodyOrigMargin;
		var bodyOrigOverflow;
		//video
		var videoIsFullScreen=false;
	    var videoOrigWidth;
		var videoOrigHeight;
		var videoOrigPosition;
		var videoOrigLeft;
		var videoOrigTop;
		//border
		var videoBorderOrigPosition;
		//video container
	    var videoContainerOrigWidth;
		var videoContainerOrigHeight;		
		var videoContainerOrigPosition;
		var videoContainerOrigLeft;
		var videoContainerOrigTop;
		//controllers
		var videoControllersOrigPosition;
		var videoControllersOrigBottom;
		//info
		var infoBoxAdjust=40;
		var infoBoxOrigPosition;
		
		var videoIsShowHideRunning=false;
		
		//timer
		var curTime;
		var totalTime;		
		
		// the skins		
		var skins = {
			skin: 'universalBlack',
			initialVolume:1,
			showInfo: true,
			autoPlayFirstMovie:false,
			autoPlay:true,
			loop:true,
			seekBarAdjust:255,
			borderWidth: 15,
			borderColor: '#e9e9e9',
			playlistWidth: 250,
			playlistCharactersLimit:100,
			numberOfThumbsPerScreen:4
		};
		var options = $.extend(skins, options);

		return this.each(function() {
			var vp2_html5_rightSidePlaylist_Video = $(this);
			
			//the controllers
			var vp2_html5_rightSidePlaylist_wrapBorder = $('<div></div>').addClass('vp2_html5_rightSidePlaylistBorder');
			var video_wrap = $('<div></div>').addClass('vp2_html5_rightSidePlaylist').addClass(options.skin);
			var vp2_html5_rightSidePlaylist_controls = $('<div class="VideoControls"><a class="VideoRewind" title="Rewind"></a><a class="VideoPlay" title="Play/Pause"></a><div class="VideoBuffer"></div><div class="VideoSeek"></div><a class="VideoShowHidePlaylist" title="Show/Hide Playlist"></a><a class="VideoInfoBut" title="Info"></a><div class="VideoTimer">00:00</div><div class="VolumeAll"><div class="VolumeSlider"></div><a class="VolumeButton" title="Mute/Unmute"></a></div><a class="VideoFullScreen" title="FullScreen"></a></div> <div class="VideoInfoBox"></div>    <div class="thumbsHolderWrapper"><div class="thumbsHolderVisibleWrapper"><div class="thumbsHolder"></div></div></div>  <div class="slider-vertical"></div>    </div>');						
			vp2_html5_rightSidePlaylist_Video.wrap(video_wrap);
			vp2_html5_rightSidePlaylist_Video.after(vp2_html5_rightSidePlaylist_controls);
			
			
			
						
			
			//the elements
			var vp2_html5_rightSidePlaylist_container = vp2_html5_rightSidePlaylist_Video.parent('.vp2_html5_rightSidePlaylist');
			
			vp2_html5_rightSidePlaylist_container.wrap(vp2_html5_rightSidePlaylist_wrapBorder);
			
			var vp2_html5_rightSidePlaylist_border = vp2_html5_rightSidePlaylist_container.parent('.vp2_html5_rightSidePlaylistBorder');
			
			
			var vp2_html5_rightSidePlaylist_controls = $('.VideoControls', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_info_box = $('.VideoInfoBox', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_rewind_btn = $('.VideoRewind', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_play_btn = $('.VideoPlay', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_Video_buffer = $('.VideoBuffer', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_Video_seek = $('.VideoSeek', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_info_btn = $('.VideoInfoBut', vp2_html5_rightSidePlaylist_container);
			if (!options.showInfo)
				vp2_html5_rightSidePlaylist_info_btn.addClass("hideElement");
			var vp2_html5_rightSidePlaylist_showHidePlaylist_btn = $('.VideoShowHidePlaylist', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_Video_timer = $('.VideoTimer', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_volumeAll = $('.VolumeAll', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_volume = $('.VolumeSlider', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_volume_btn = $('.VolumeButton', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_fullscreen_btn = $('.VideoFullScreen', vp2_html5_rightSidePlaylist_container);
			
			//set controllers size
			vp2_html5_rightSidePlaylist_controls.width(vp2_html5_rightSidePlaylist_Video.width());
			
			//set border size
			vp2_html5_rightSidePlaylist_border.width(vp2_html5_rightSidePlaylist_Video.width()+3*options.borderWidth+options.playlistWidth);			
			vp2_html5_rightSidePlaylist_border.height(vp2_html5_rightSidePlaylist_Video.height()+2*options.borderWidth);
			vp2_html5_rightSidePlaylist_border.css("background",options.borderColor);
			
			vp2_html5_rightSidePlaylist_container.css('top',options.borderWidth+'px');
			vp2_html5_rightSidePlaylist_container.css('left',options.borderWidth+'px');
			
			
			//set seekbar width
			vp2_html5_rightSidePlaylist_Video_seek.css( 'width', vp2_html5_rightSidePlaylist_Video[0].offsetWidth-options.seekBarAdjust + 'px');
			vp2_html5_rightSidePlaylist_Video_buffer.css( 'width', vp2_html5_rightSidePlaylist_Video_seek.css( 'width'));
			
			//set info box
			vp2_html5_rightSidePlaylist_info_box.css( 'width', vp2_html5_rightSidePlaylist_Video[0].offsetWidth-infoBoxAdjust + 'px');
			//vp2_html5_rightSidePlaylist_info_box.html( '<p class="movieTitle">'+options.movieTitle+'</p><p class="movieDesc">'+options.movieDesc+'</p>');
			
			
			vp2_html5_rightSidePlaylist_controls.hide(); // the controls are still hidden
			
			
			
			  videoOrigWidth = vp2_html5_rightSidePlaylist_Video[0].offsetWidth;
			  videoOrigHeight = vp2_html5_rightSidePlaylist_Video[0].offsetHeight;
			  
			  videoContainerOrigWidth = vp2_html5_rightSidePlaylist_container[0].offsetWidth;
			  videoContainerOrigHeight = vp2_html5_rightSidePlaylist_container[0].offsetHeight;	
			  
			  videoBorderOrigPosition =  vp2_html5_rightSidePlaylist_border.css('position');
			  
			  //body
			  bodyOrigMargin=$("body").css("margin");
			  bodyOrigOverflow=$("body").css("overflow");				  
			
			
			var detectBrowserAndVideo = function(){
				//activate current
				$(thumbsHolder_Thumbs[current_img_no]).addClass('thumbsHolder_ThumbON');
				//auto scroll carousel if needed
				carouselScroll();
				
				var currentVideo=playlist_arr[current_img_no]['sources_webm'];
				var val = navigator.userAgent.toLowerCase();
				if (val.indexOf("opera") != -1 || val.indexOf("firefox") != -1  || val.indexOf("mozzila") != -1) 
					currentVideo=playlist_arr[current_img_no]['sources_ogv'];
				
				if (val.indexOf("chrome") != -1 || val.indexOf("msie") != -1 || val.indexOf("safari") != -1)
					currentVideo=playlist_arr[current_img_no]['sources_mp4'];
				
				if (val.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i))
					currentVideo=playlist_arr[current_img_no]['sources_webm'];
				
				//var val = this.dataBrowser;
				//alert (currentVideo+ '  --  ' +val);
				return currentVideo;
			};			
			
			//generate playlist
			var isCarouselScrolling=false;
			var currentCarouselTop=0;
			var vp2_html5_rightSidePlaylist_thumbsHolderWrapper = $('.thumbsHolderWrapper', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_thumbsHolderVisibleWrapper = $('.thumbsHolderVisibleWrapper', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_thumbsHolder = $('.thumbsHolder', vp2_html5_rightSidePlaylist_container);
			var vp2_html5_rightSidePlaylist_sliderVertical = $('.slider-vertical', vp2_html5_rightSidePlaylist_container);			
			
			vp2_html5_rightSidePlaylist_thumbsHolderVisibleWrapper.width(options.playlistWidth);
			vp2_html5_rightSidePlaylist_thumbsHolderVisibleWrapper.height(vp2_html5_rightSidePlaylist_container.height());
			//vp2_html5_rightSidePlaylist_thumbsHolderVisibleWrapper.css('top',0);
			
			
			vp2_html5_rightSidePlaylist_thumbsHolderWrapper.width(options.playlistWidth);
			vp2_html5_rightSidePlaylist_thumbsHolderWrapper.height(vp2_html5_rightSidePlaylist_container.height());
			vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css("top",0);
			vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css("left",+vp2_html5_rightSidePlaylist_Video[0].offsetWidth+options.borderWidth+'px');
			
			
			vp2_html5_rightSidePlaylist_thumbsHolder.width(options.playlistWidth);
			vp2_html5_rightSidePlaylist_thumbsHolder.css('top',options.borderWidth+'px');
			
			var thumbMarginTop=0;
			var current_img_no=0;
			var total_images=0;
			var playlist_arr=new Array();
			
			var playlistElements = $('#playlist').children();
			playlistElements.each(function() { // ul-s
	            currentElement = $(this);
	            total_images++;
	            playlist_arr[total_images-1]=new Array();
	            playlist_arr[total_images-1]['title']='';
	            playlist_arr[total_images-1]['desc']='';
	            playlist_arr[total_images-1]['thumb']='';
	            playlist_arr[total_images-1]['preview']='';
	            playlist_arr[total_images-1]['xsources_mp4']='';
	            playlist_arr[total_images-1]['xsources_ogv']='';
	            playlist_arr[total_images-1]['xsources_webm']='';
	            playlist_arr[total_images-1]['xsources_mp4v']='';
	            
	            //alert (currentElement.find('.xdesc').html())
	            if (currentElement.find('.xtitle').html()!=null) {
	            	playlist_arr[total_images-1]['title']=currentElement.find('.xtitle').html();
	            }	            
	            
	            if (currentElement.find('.xdesc').html()!=null) {
	            	playlist_arr[total_images-1]['desc']=currentElement.find('.xdesc').html();
	            }
	            
	            if (currentElement.find('.xthumb').html()!=null) {
	            	playlist_arr[total_images-1]['thumb']=currentElement.find('.xthumb').html();
	            }
	            
	            if (currentElement.find('.xpreview').html()!=null) {
	            	playlist_arr[total_images-1]['preview']=currentElement.find('.xpreview').html();
	            }
	            
	            
	            if (currentElement.find('.xsources_mp4').html()!=null) {
	            	playlist_arr[total_images-1]['sources_mp4']=currentElement.find('.xsources_mp4').html();
	            }	  
	            
	            if (currentElement.find('.xsources_ogv').html()!=null) {
	            	playlist_arr[total_images-1]['sources_ogv']=currentElement.find('.xsources_ogv').html();
	            }

	            if (currentElement.find('.xsources_webm').html()!=null) {
	            	playlist_arr[total_images-1]['sources_webm']=currentElement.find('.xsources_webm').html();
	            }	  
	            
	            if (currentElement.find('.xsources_mp4v').html()!=null) {
	            	playlist_arr[total_images-1]['sources_mp4v']=currentElement.find('.xsources_mp4v').html();
	            }	            
	            
	            desc_aux=String(playlist_arr[total_images-1]['desc']);
	            //substr(0,options.playlistCharactersLimit);
	            if (desc_aux.length>options.playlistCharactersLimit)
	            	desc_aux=desc_aux.substr(0,desc_aux.indexOf(' ', options.playlistCharactersLimit))+'...';
	            
	            thumbsHolder_Thumb = $('<div class="thumbsHolder_ThumbOFF" rel="'+ (total_images-1) +'"><div class="padding"><img src="' + playlist_arr[total_images-1]['thumb'] + '"><span class="title">'+playlist_arr[total_images-1]['title']+'</span><br><span class="reg">'+desc_aux+'</span></div></div>');
	            vp2_html5_rightSidePlaylist_thumbsHolder.append(thumbsHolder_Thumb);
	            
	            //activate first
	            if (total_images===1)
	            	thumbsHolder_Thumb.addClass('thumbsHolder_ThumbON');
	            
	            thumbMarginTop=Math.floor( (vp2_html5_rightSidePlaylist_thumbsHolderWrapper.height()-thumbsHolder_Thumb.height()*options.numberOfThumbsPerScreen)/(options.numberOfThumbsPerScreen-1) );
	            //alert(vp2_html5_rightSidePlaylist_thumbsHolderWrapper.height());
	            vp2_html5_rightSidePlaylist_thumbsHolder.css('height',vp2_html5_rightSidePlaylist_thumbsHolder.height()+thumbMarginTop+thumbsHolder_Thumb.height()+'px');
	            if ( total_images<=1 ) {
	            	thumbsHolder_Thumb.css('margin-top',Math.floor( ( vp2_html5_rightSidePlaylist_thumbsHolderWrapper.height()-2*options.borderWidth-(thumbMarginTop+thumbsHolder_Thumb.height())*(options.numberOfThumbsPerScreen-1) - thumbsHolder_Thumb.height() )/2 )+'px');
	            } else {
	            	thumbsHolder_Thumb.css('margin-top',thumbMarginTop+'px');
	            }
	            	
	            
	            thumbsHolder_MarginTop=parseInt((vp2_html5_rightSidePlaylist_thumbsHolderWrapper.height()-parseInt(thumbsHolder_Thumb.css('height').substring(0, thumbsHolder_Thumb.css('height').length-2)))/2);	            
	            
			});
			
			
            //the scroller
			if (total_images>options.numberOfThumbsPerScreen) {
				vp2_html5_rightSidePlaylist_sliderVertical.slider({
					orientation: "vertical",
					range: "min",
					min: 1,
					max: 100,
					step:1,
					value: 100,
					slide: function( event, ui ) {
						//alert( ui.value );
						carouselScroll(ui.value);
					}
				});
				vp2_html5_rightSidePlaylist_sliderVertical.css('display','block');
            	vp2_html5_rightSidePlaylist_sliderVertical.height(vp2_html5_rightSidePlaylist_thumbsHolderWrapper.height()-25); // 25 is the height of  .slider-vertical.ui-slider .ui-slider-handle 
            	vp2_html5_rightSidePlaylist_sliderVertical.css('left',Math.floor(vp2_html5_rightSidePlaylist_Video[0].offsetWidth+options.borderWidth+options.playlistWidth+(options.borderWidth-vp2_html5_rightSidePlaylist_sliderVertical.width())/2)+'px');
            	//vp2_html5_rightSidePlaylist_sliderVertical.css('left',Math.floor(vp2_html5_rightSidePlaylist_Video[0].offsetWidth)+2+'px');
            }			

			
			var carouselScroll = function (direction) {
				var MAX_TOP=(thumbsHolder_Thumb.height()+thumbMarginTop)*(total_images-1);
				//alert (vp2_html5_rightSidePlaylist_sliderVertical.slider( "option", "animate" ));
				vp2_html5_rightSidePlaylist_thumbsHolder.stop(true,true);
				if (direction && !isCarouselScrolling) {
					
					isCarouselScrolling=true;
					//vp2_html5_rightSidePlaylist_thumbsHolder.css('opacity','0.5');
					
					
					vp2_html5_rightSidePlaylist_thumbsHolder.animate({
					    //opacity: 1,
					    top:parseInt(options.borderWidth+MAX_TOP*(direction-100)/100)+'px'
					  }, 1100, 'easeOutQuad', function() {
					    // Animation complete.
						  isCarouselScrolling=false;
					});
				} else if (!isCarouselScrolling) {
					isCarouselScrolling=true;
					vp2_html5_rightSidePlaylist_thumbsHolder.css('opacity','0.5');			
					var new_top=parseInt(options.borderWidth-(thumbsHolder_Thumb.height()+thumbMarginTop)*current_img_no);
					vp2_html5_rightSidePlaylist_sliderVertical.slider( "value" , 100 + parseInt( new_top * 100 / MAX_TOP ) );
					vp2_html5_rightSidePlaylist_thumbsHolder.animate({
					    opacity: 1,
					    top:new_top+'px'
					  }, 500, 'easeOutCubic', function() {
					    // Animation complete.
						  isCarouselScrolling=false;
					});
				}
			}
			
			
			// mouse wheel
			vp2_html5_rightSidePlaylist_thumbsHolderVisibleWrapper.mousewheel(function(event, delta, deltaX, deltaY) {
				event.preventDefault();
				var currentScrollVal=vp2_html5_rightSidePlaylist_sliderVertical.slider( "value");
				//alert (currentScrollVal+' -- '+delta);
				if ( (parseInt(currentScrollVal)>1 && parseInt(delta)==-1) || (parseInt(currentScrollVal)<100 && parseInt(delta)==1) ) {
					currentScrollVal = currentScrollVal + delta;
					vp2_html5_rightSidePlaylist_sliderVertical.slider( "value", currentScrollVal);
					carouselScroll(currentScrollVal);
					//alert (currentScrollVal);
				}
				
			});			
			
			
			//tumbs nav
			var thumbsHolder_Thumbs=$(".thumbsHolder_ThumbOFF");
			thumbsHolder_Thumbs.click(function() {
					var currentBut=$(this);
					var i=currentBut.attr('rel');
					//alert (current_img_no+'  --  '+i)
					//deactivate previous 
					$(thumbsHolder_Thumbs[current_img_no]).removeClass('thumbsHolder_ThumbON');
					
					current_img_no=i;
					changeSrcAndPoster(options.autoPlay);
			});
			
			thumbsHolder_Thumbs.mouseenter(function() {
				var currentBut=$(this);
				var i=currentBut.attr('rel');
				
				currentBut.addClass('thumbsHolder_ThumbON');
			});
			
			thumbsHolder_Thumbs.mouseleave(function() {
				var currentBut=$(this);
				var i=currentBut.attr('rel');

				if (current_img_no!=i)
					currentBut.removeClass('thumbsHolder_ThumbON');
			});					
			
			
			var changeSrcAndPoster = function (auto_play) {
				//seekbar init
				vp2_html5_rightSidePlaylist_Video_seek.slider("destroy");
				vp2_html5_rightSidePlaylist_Video_buffer.progressbar("destroy");
				vp2_html5_rightSidePlaylist_Video.unbind('progress');				
				
				vp2_html5_rightSidePlaylist_Video[0].poster=playlist_arr[current_img_no]['preview'];
				//info
				vp2_html5_rightSidePlaylist_info_box.html( '<p class="movieTitle">'+playlist_arr[current_img_no]['title']+'</p><p class="movieDesc">'+playlist_arr[current_img_no]['desc']+'</p>');
				
				vp2_html5_rightSidePlaylist_Video[0].src=detectBrowserAndVideo();
				vp2_html5_rightSidePlaylist_Video[0].load();
				if (auto_play) {
					vp2_html5_rightSidePlaylist_Video[0].play();
					vp2_html5_rightSidePlaylist_play_btn.addClass('VideoPause');
				} else {
					vp2_html5_rightSidePlaylist_play_btn.removeClass('VideoPause');
				}
				

				generate_seekBar();
			}
			
			//initialize first video
			changeSrcAndPoster(options.autoPlayFirstMovie);			
			
			
			
			
			/* rewind */
			vp2_html5_rightSidePlaylist_rewind_btn.click(function() {
				vp2_html5_rightSidePlaylist_Video.attr("currentTime",0);
				vp2_html5_rightSidePlaylist_Video[0].play();				
			});
			/* play/pause*/			
			var vp2_html5_rightSidePlaylist_PlayPause = function() {
				if(vp2_html5_rightSidePlaylist_Video.attr('paused') == false) {
					vp2_html5_rightSidePlaylist_Video[0].pause();					
				} else {					
					vp2_html5_rightSidePlaylist_Video[0].play();				
				}
			};
			
			vp2_html5_rightSidePlaylist_play_btn.click(vp2_html5_rightSidePlaylist_PlayPause);
			vp2_html5_rightSidePlaylist_Video.click(vp2_html5_rightSidePlaylist_PlayPause);
			
			vp2_html5_rightSidePlaylist_Video.bind('play', function() {
				vp2_html5_rightSidePlaylist_play_btn.addClass('VideoPause');
			});
			
			vp2_html5_rightSidePlaylist_Video.bind('pause', function() {
				vp2_html5_rightSidePlaylist_play_btn.removeClass('VideoPause');
			});
			
			/*vp2_html5_rightSidePlaylist_Video.bind('ended', function() {
				vp2_html5_rightSidePlaylist_play_btn.removeClass('VideoPause');
			});*/
		
			
			
			//show controllers on mouser over / hide controllers on mouse out
			vp2_html5_rightSidePlaylist_container.mouseover(function() {
				vp2_html5_rightSidePlaylist_controls.show();
			});
			vp2_html5_rightSidePlaylist_container.mouseout(function() {
				if (vp2_html5_rightSidePlaylist_volumeAll.css('height').substring(0, vp2_html5_rightSidePlaylist_volumeAll.css('height').length-2) < 120) {
					vp2_html5_rightSidePlaylist_controls.hide();
				}
			});		
			//play/pause using spacebar
			vp2_html5_rightSidePlaylist_container.keydown(function(evt) {
    			if (evt.keyCode == 32) 
					vp2_html5_rightSidePlaylist_PlayPause();
    		});	
			//fullscreen
			var fullScreenOn = function(){
			  videoIsFullScreen = true;
			  //change button
			  vp2_html5_rightSidePlaylist_fullscreen_btn.removeClass('VideoFullScreen');
			  vp2_html5_rightSidePlaylist_fullscreen_btn.addClass('VideoFullScreenIn');
			  
			  //preserve original/nonFullScreen values
			  videoOrigPosition = vp2_html5_rightSidePlaylist_Video.css( 'position');
			  videoOrigLeft = vp2_html5_rightSidePlaylist_Video.css( 'left');
			  videoOrigTop = vp2_html5_rightSidePlaylist_Video.css( 'top');
			  
		  
			  videoContainerOrigPosition = vp2_html5_rightSidePlaylist_container.css( 'position');
			  videoContainerOrigLeft = vp2_html5_rightSidePlaylist_container.css( 'left');
			  videoContainerOrigTop = vp2_html5_rightSidePlaylist_container.css( 'top');
			  videoControllersOrigPosition = vp2_html5_rightSidePlaylist_controls.css( 'position');
			  videoControllersOrigBottom = vp2_html5_rightSidePlaylist_controls.css( 'bottom');
			  
			  infoBoxOrigPosition=vp2_html5_rightSidePlaylist_info_box.css( 'position');

			  
			  $("body").css("overflow", "hidden");
			  //$("body").css("background", "#000000");
			  $(".vp2_html5_rightSidePlaylist").css('display','none');
			  vp2_html5_rightSidePlaylist_container.css('display','block');

			  $("body").css("margin",0);
			  
			  //border
			  vp2_html5_rightSidePlaylist_border.css('position','fixed');
			  vp2_html5_rightSidePlaylist_border.css('top',0);
			  vp2_html5_rightSidePlaylist_border.css('left',0);
			  vp2_html5_rightSidePlaylist_border.css( 'width', window.innerWidth + "px" );
			  vp2_html5_rightSidePlaylist_border.css( 'height', window.innerWidth + "px" );
			  vp2_html5_rightSidePlaylist_border.css( 'background', "#000000" );			  
			  
			  //container
			  vp2_html5_rightSidePlaylist_container.css( 'position', 'absolute' );
			  //vp2_html5_rightSidePlaylist_container.css( 'width', window.innerWidth + "px" );
			  //vp2_html5_rightSidePlaylist_container.css( 'height', window.innerWidth + "px" );
			  //vp2_html5_rightSidePlaylist_container.css( 'width', "10000px" );
			  //vp2_html5_rightSidePlaylist_container.css( 'height', "20000px" );			  
			  vp2_html5_rightSidePlaylist_container.css( 'top', 0 );			  
			  vp2_html5_rightSidePlaylist_container.css( 'left', 0 );			  
			  
			  //video
			  vp2_html5_rightSidePlaylist_Video.css( 'position', 'fixed' );
			  if (vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css('display')!='none') {
			  	vp2_html5_rightSidePlaylist_Video.css( 'width', window.innerWidth-2*options.borderWidth-options.playlistWidth + "px" );
			  	vp2_html5_rightSidePlaylist_info_box.css( 'width', window.innerWidth-2*options.borderWidth-options.playlistWidth-infoBoxAdjust + 'px');
			  } else {
				vp2_html5_rightSidePlaylist_Video.css( 'width', window.innerWidth + "px" ); 
				vp2_html5_rightSidePlaylist_info_box.css( 'width', window.innerWidth-infoBoxAdjust + 'px');
			  }
			  vp2_html5_rightSidePlaylist_Video.css( 'height', window.innerHeight + "px" );
			  vp2_html5_rightSidePlaylist_Video.css( 'top', 0 );			  
			  vp2_html5_rightSidePlaylist_Video.css( 'left', 0 );
		  

			  //controller
			  vp2_html5_rightSidePlaylist_controls.css( 'position', 'fixed');
			  vp2_html5_rightSidePlaylist_controls.css( 'bottom', videoControllersOrigBottom);
			  vp2_html5_rightSidePlaylist_controls.width(vp2_html5_rightSidePlaylist_Video.width());
			  vp2_html5_rightSidePlaylist_Video_seek.css( 'width', vp2_html5_rightSidePlaylist_Video.width()-options.seekBarAdjust + 'px');
			  vp2_html5_rightSidePlaylist_Video_buffer.css( 'width', vp2_html5_rightSidePlaylist_Video_seek.css( 'width'));
			  //info box
			  
			  vp2_html5_rightSidePlaylist_info_box.css( 'position', 'fixed');
			  
			  //playlist
			  //alert (vp2_html5_rightSidePlaylist_Video[0].offsetWidth+ '   -   '+ vp2_html5_rightSidePlaylist_Video.width())
			  vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css("left",+vp2_html5_rightSidePlaylist_Video[0].offsetWidth+options.borderWidth+'px');
			  vp2_html5_rightSidePlaylist_thumbsHolderWrapper.height(window.innerHeight);
			  vp2_html5_rightSidePlaylist_thumbsHolderVisibleWrapper.height(window.innerHeight);
			  vp2_html5_rightSidePlaylist_sliderVertical.height(vp2_html5_rightSidePlaylist_thumbsHolderWrapper.height()-25);
			  var aux_val=(options.borderWidth-vp2_html5_rightSidePlaylist_sliderVertical.width())/2;
			  if (aux_val<0)
			  	aux_val=options.borderWidth-vp2_html5_rightSidePlaylist_sliderVertical.width();
			  vp2_html5_rightSidePlaylist_sliderVertical.css('left',Math.floor(vp2_html5_rightSidePlaylist_Video[0].offsetWidth+options.borderWidth+options.playlistWidth+aux_val)+'px');
			}
			
			
			var fullScreenOff = function(){
			  videoIsFullScreen = false;
			  
			  
			  //change button
			  vp2_html5_rightSidePlaylist_fullscreen_btn.removeClass('VideoFullScreenIn');
			  vp2_html5_rightSidePlaylist_fullscreen_btn.addClass('VideoFullScreen');			  
			  
			  $(".vp2_html5_rightSidePlaylist").css('display','block');
			  
			  //body
			  $("body").css("margin",bodyOrigMargin);	
			  $("body").css("overflow", bodyOrigOverflow);
			  
			  //video
			  vp2_html5_rightSidePlaylist_Video.css( 'position', videoOrigPosition );
			  if (vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css('display')!='none') {
				  vp2_html5_rightSidePlaylist_Video.css( 'width', videoOrigWidth + "px" );
			  } else {
				  vp2_html5_rightSidePlaylist_Video.css( 'width', videoOrigWidth + options.borderWidth + options.playlistWidth + "px" );
			  }			  
			  
			  vp2_html5_rightSidePlaylist_Video.css( 'height', videoOrigHeight + "px" );
			  vp2_html5_rightSidePlaylist_Video.css( 'top', videoOrigTop );			  
			  vp2_html5_rightSidePlaylist_Video.css( 'left', videoOrigLeft );
			  
			  //border
			  vp2_html5_rightSidePlaylist_border.css('position',videoBorderOrigPosition);
			  vp2_html5_rightSidePlaylist_border.css( 'width', videoOrigWidth+3*options.borderWidth+options.playlistWidth + "px" );
			  vp2_html5_rightSidePlaylist_border.css( 'height', videoOrigHeight+2*options.borderWidth + "px" );  
	  
			  
			  vp2_html5_rightSidePlaylist_border.css( 'background', options.borderColor );	
			  
			  //container
			  vp2_html5_rightSidePlaylist_container.css( 'position', videoContainerOrigPosition );
			  /*if (vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css('display')!='none') {
			  	vp2_html5_rightSidePlaylist_container.css( 'width', videoContainerOrigWidth-options.borderWidth + "px" );
			  	vp2_html5_rightSidePlaylist_container.css( 'height', videoContainerOrigHeight + "px" );
			  } else {
				vp2_html5_rightSidePlaylist_container.css( 'width', videoContainerOrigWidth+options.borderWidth+options.playlistWidth + "px" );
			  	vp2_html5_rightSidePlaylist_container.css( 'height', videoContainerOrigHeight + "px" );  
			  }*/
			  vp2_html5_rightSidePlaylist_container.css( 'top', videoContainerOrigTop );			  
			  vp2_html5_rightSidePlaylist_container.css( 'left', videoContainerOrigLeft );
			  //controllers
			  vp2_html5_rightSidePlaylist_controls.css( 'position', videoControllersOrigPosition);
			  vp2_html5_rightSidePlaylist_controls.css( 'bottom', videoControllersOrigBottom);
			  vp2_html5_rightSidePlaylist_controls.width(vp2_html5_rightSidePlaylist_Video.width());
			  vp2_html5_rightSidePlaylist_Video_seek.css( 'width', vp2_html5_rightSidePlaylist_Video[0].offsetWidth-options.seekBarAdjust + 'px');
			  vp2_html5_rightSidePlaylist_Video_buffer.css( 'width', vp2_html5_rightSidePlaylist_Video_seek.css( 'width'));
			  //info box
			  vp2_html5_rightSidePlaylist_info_box.css( 'width', vp2_html5_rightSidePlaylist_container.width()-infoBoxAdjust + 'px');
			  vp2_html5_rightSidePlaylist_info_box.css( 'position', infoBoxOrigPosition);
			  
			  
			  //playlist
			  vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css("left",+videoOrigWidth+options.borderWidth+'px');
			  vp2_html5_rightSidePlaylist_thumbsHolderWrapper.height(videoOrigHeight);
			  vp2_html5_rightSidePlaylist_thumbsHolderVisibleWrapper.height(videoOrigHeight);
			  vp2_html5_rightSidePlaylist_sliderVertical.height(videoOrigHeight-25);
			  vp2_html5_rightSidePlaylist_sliderVertical.css('left',Math.floor(videoOrigWidth+options.borderWidth+options.playlistWidth+(options.borderWidth-vp2_html5_rightSidePlaylist_sliderVertical.width())/2)+'px');
			}
			


			var handleFullScreen = function(){
				if (!videoIsFullScreen) {
					fullScreenOn();
				} else {
					fullScreenOff();
				}
			}
			
/*			vp2_html5_rightSidePlaylist_container.dblclick(function() {
			  handleFullScreen();
			});*/			
			
			vp2_html5_rightSidePlaylist_fullscreen_btn.click(function() {
			  handleFullScreen();
			});			
			
			
			// timer mouse over
			var is_overTimer=false;
			vp2_html5_rightSidePlaylist_Video_timer.mouseover(function() {
				is_overTimer=true;
				curTime = vp2_html5_rightSidePlaylist_Video.attr('currentTime');
				totalTime = vp2_html5_rightSidePlaylist_Video.attr('duration');					
				vp2_html5_rightSidePlaylist_Video_timer.text('-'+vp2_html5_rightSidePlaylist_FormatTime(totalTime-curTime));
			});	
			vp2_html5_rightSidePlaylist_Video_timer.mouseout(function() {
				is_overTimer=false;
				curTime = vp2_html5_rightSidePlaylist_Video.attr('currentTime');
				totalTime = vp2_html5_rightSidePlaylist_Video.attr('duration');					
				vp2_html5_rightSidePlaylist_Video_timer.text(vp2_html5_rightSidePlaylist_FormatTime(curTime));
			});				

			

			
			var is_seeking=false;			
			function generate_seekBar() {
				//alert ("gen");
				if(vp2_html5_rightSidePlaylist_Video.attr('readyState')) {
					totalTime = vp2_html5_rightSidePlaylist_Video.attr('duration');
					vp2_html5_rightSidePlaylist_Video_seek.slider({
						value: 0,
						step: 0.01,
						orientation: "horizontal",
						range: "min",
						max: totalTime,
						animate: true,					
						slide: function(){							
							is_seeking = true;
						},
						stop:function(e,ui){
							is_seeking = false;						
							vp2_html5_rightSidePlaylist_Video.attr("currentTime",ui.value);
						}
					});
					
					
					var bufferedTime=0;
					vp2_html5_rightSidePlaylist_Video_buffer.progressbar({ 
						value: bufferedTime
					});
					
					vp2_html5_rightSidePlaylist_Video.bind('progress', function() {
						//alert(vp2_html5_rightSidePlaylist_Video.attr("buffered").end(vp2_html5_rightSidePlaylist_Video.attr("buffered").length-1));
						bufferedTime = vp2_html5_rightSidePlaylist_Video.attr("buffered").end(vp2_html5_rightSidePlaylist_Video.attr("buffered").length-1); 
						//alert (bufferedTime);
						if (bufferedTime>0) {
							vp2_html5_rightSidePlaylist_Video_buffer.progressbar({ value: bufferedTime*vp2_html5_rightSidePlaylist_Video_buffer.css( 'width' ).substring(0, vp2_html5_rightSidePlaylist_Video_buffer.css( 'width' ).length-2)/totalTime });
						}
					});						

					vp2_html5_rightSidePlaylist_controls.show();
				} else {
					setTimeout(generate_seekBar, 200);
				}
			};

			generate_seekBar();
		
			var vp2_html5_rightSidePlaylist_FormatTime=function(seconds){
				var m=Math.floor(seconds/60)<10?"0"+Math.floor(seconds/60):Math.floor(seconds/60);
				var s=Math.floor(seconds-(m*60))<10?"0"+Math.floor(seconds-(m*60)):Math.floor(seconds-(m*60));
				return m+":"+s;
			};
			
			var seekUpdate = function() {
				curTime = vp2_html5_rightSidePlaylist_Video.attr('currentTime');
				totalTime = vp2_html5_rightSidePlaylist_Video.attr('duration');
				if(!is_seeking) vp2_html5_rightSidePlaylist_Video_seek.slider('value', curTime);
				if (!is_overTimer)
					vp2_html5_rightSidePlaylist_Video_timer.text(vp2_html5_rightSidePlaylist_FormatTime(curTime));
				else
					vp2_html5_rightSidePlaylist_Video_timer.text('-'+vp2_html5_rightSidePlaylist_FormatTime(totalTime-curTime));
			};
			
			vp2_html5_rightSidePlaylist_Video.bind('timeupdate', seekUpdate);
			
			//info
			//var vp2_html5_rightSidePlaylist_info_btn = $('.VideoInfoBut', vp2_html5_rightSidePlaylist_container);
			vp2_html5_rightSidePlaylist_info_btn.click(function() {
				if (options.skin=="giant") {
					if (vp2_html5_rightSidePlaylist_info_box.css("display")=="none")
						vp2_html5_rightSidePlaylist_info_box.fadeIn();
					else
						vp2_html5_rightSidePlaylist_info_box.fadeOut();	
				} else { 
					vp2_html5_rightSidePlaylist_info_box.slideToggle(300);
				}
			});
			
			//show/hide playlist
			vp2_html5_rightSidePlaylist_showHidePlaylist_btn.click(function() {
				if (!videoIsShowHideRunning) {
					videoIsShowHideRunning=true;
					if (vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css('display')!='none') { //hide
						var new_width;
						new_width=vp2_html5_rightSidePlaylist_Video[0].offsetWidth+options.borderWidth+options.playlistWidth;
						if (videoIsFullScreen)
							new_width=new_width+options.borderWidth;
						
						vp2_html5_rightSidePlaylist_showHidePlaylist_btn.addClass('VideoShowHidePlaylist_onlyShow');
						
						
						if (videoIsFullScreen) {
							vp2_html5_rightSidePlaylist_Video_seek.width(vp2_html5_rightSidePlaylist_Video_seek.width()+2*options.borderWidth+options.playlistWidth);
							vp2_html5_rightSidePlaylist_Video_buffer.width(vp2_html5_rightSidePlaylist_Video_buffer.width()+2*options.borderWidth+options.playlistWidth);	
							
							vp2_html5_rightSidePlaylist_info_box.width(vp2_html5_rightSidePlaylist_info_box.width()+2*options.borderWidth+options.playlistWidth);
						} else {
							vp2_html5_rightSidePlaylist_Video_seek.width(vp2_html5_rightSidePlaylist_Video_seek.width()+options.borderWidth+options.playlistWidth);
							vp2_html5_rightSidePlaylist_Video_buffer.width(vp2_html5_rightSidePlaylist_Video_buffer.width()+options.borderWidth+options.playlistWidth);
							
							vp2_html5_rightSidePlaylist_info_box.width(vp2_html5_rightSidePlaylist_info_box.width()+options.borderWidth+options.playlistWidth);
							
						  	//vp2_html5_rightSidePlaylist_container.css( 'width', videoContainerOrigWidth+options.borderWidth+options.playlistWidth + "px" );
							//vp2_html5_rightSidePlaylist_container.css( 'height', videoContainerOrigHeight + "px" );
						
						}					
						vp2_html5_rightSidePlaylist_sliderVertical.css('display','none');
						vp2_html5_rightSidePlaylist_thumbsHolderWrapper.animate({
						    opacity: 0
						  }, 300, function() {
							  vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css('display','none');
						  }
						);
						
	
						vp2_html5_rightSidePlaylist_controls.css('opacity',0);
						vp2_html5_rightSidePlaylist_controls.animate({
						    width: new_width,
						    opacity: 1
						  }, 300, function() {
						    // Animation complete.
						  }
						);
						
						
						vp2_html5_rightSidePlaylist_Video.animate({
						    width: new_width
						  }, 300, function() {
						    // Animation complete.
							  videoIsShowHideRunning=false;
						  }
						);					
					} else { //show
						new_width=vp2_html5_rightSidePlaylist_Video[0].offsetWidth-options.borderWidth-options.playlistWidth;
						if (videoIsFullScreen)
							new_width=new_width-options.borderWidth;					
						
						vp2_html5_rightSidePlaylist_showHidePlaylist_btn.removeClass('VideoShowHidePlaylist_onlyShow');
						
						if (videoIsFullScreen) {
							vp2_html5_rightSidePlaylist_Video_seek.width(vp2_html5_rightSidePlaylist_Video_seek.width()-2*options.borderWidth-options.playlistWidth);
							vp2_html5_rightSidePlaylist_Video_buffer.width(vp2_html5_rightSidePlaylist_Video_buffer.width()-2*options.borderWidth-options.playlistWidth);
							
							vp2_html5_rightSidePlaylist_info_box.width(vp2_html5_rightSidePlaylist_info_box.width()-2*options.borderWidth-options.playlistWidth);
						} else {
							vp2_html5_rightSidePlaylist_Video_seek.width(vp2_html5_rightSidePlaylist_Video_seek.width()-options.borderWidth-options.playlistWidth);
							vp2_html5_rightSidePlaylist_Video_buffer.width(vp2_html5_rightSidePlaylist_Video_buffer.width()-options.borderWidth-options.playlistWidth);
							
							vp2_html5_rightSidePlaylist_info_box.width(vp2_html5_rightSidePlaylist_info_box.width()-options.borderWidth-options.playlistWidth);
							
						  	//vp2_html5_rightSidePlaylist_container.css( 'width', videoContainerOrigWidth + "px" );
							//vp2_html5_rightSidePlaylist_container.css( 'height', videoContainerOrigHeight + "px" );						
						}
						
						vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css('display','block');
						vp2_html5_rightSidePlaylist_sliderVertical.css('display','block');
						vp2_html5_rightSidePlaylist_thumbsHolderWrapper.animate({
						    opacity: 1
						  }, 600, function() {
							// Animation complete.
							  videoIsShowHideRunning=false;
							  carouselScroll();
						  }
						);						
						
	
						vp2_html5_rightSidePlaylist_controls.css('opacity',0);
						vp2_html5_rightSidePlaylist_controls.animate({
						    width: new_width,
						    opacity: 1
						  }, 300, function() {
						    // Animation complete.
						  }
						);
						
						vp2_html5_rightSidePlaylist_thumbsHolderWrapper.css("left",+new_width    +options.borderWidth+'px');
						vp2_html5_rightSidePlaylist_sliderVertical.css('left',Math.floor(new_width   +options.borderWidth+options.playlistWidth+(options.borderWidth-vp2_html5_rightSidePlaylist_sliderVertical.width())/2)+'px');
						vp2_html5_rightSidePlaylist_Video.animate({
						    width: new_width
						  }, 300, function() {
						    // Animation complete.
						  }
						);					
					}
				}
			});			
	
		
			//movie ended
			vp2_html5_rightSidePlaylist_Video[0].addEventListener('ended',endMovieHandler,false);
		    function endMovieHandler(e) {
		        if(!e) { e = window.event; }
		        // What you want to do after the event
		        //alert ("ended");
		        if (options.loop) {
		        	//alert (current_img_no);
		        	//deactivate previous
					$(thumbsHolder_Thumbs[current_img_no]).removeClass('thumbsHolder_ThumbON');
							        	
		        	if (current_img_no==total_images-1)
		        		current_img_no=0;
		        	else
		        		current_img_no++;
		        	
		        	changeSrcAndPoster(options.autoPlay);
		        }
		    }

			
			
			
			var vp2_html5_rightSidePlaylist_VolumeValue = 1;
			vp2_html5_rightSidePlaylist_volume.slider({
				value: options.initialVolume,
				orientation: "vertical",
				range: "min",
				max: 1,
				step: 0.05,
				animate: true,
				slide:function(e,ui){
						vp2_html5_rightSidePlaylist_Video.attr('muted',false);
						vp2_html5_rightSidePlaylist_VolumeValue = ui.value;
						vp2_html5_rightSidePlaylist_Video.attr('volume',ui.value);
					}
			});
			vp2_html5_rightSidePlaylist_Video.attr('volume',options.initialVolume);
			
			var muteVolume = function() {
				if(vp2_html5_rightSidePlaylist_Video.attr('muted')==true) {
					vp2_html5_rightSidePlaylist_Video.attr('muted', false);
					vp2_html5_rightSidePlaylist_volume.slider('value', vp2_html5_rightSidePlaylist_VolumeValue);
					
					vp2_html5_rightSidePlaylist_volume_btn.removeClass('VolumeButtonMute');
					vp2_html5_rightSidePlaylist_volume_btn.addClass('VolumeButton');					
				} else {
					vp2_html5_rightSidePlaylist_Video.attr('muted', true);
					vp2_html5_rightSidePlaylist_volume.slider('value', '0');
					
					vp2_html5_rightSidePlaylist_volume_btn.removeClass('VolumeButton');
					vp2_html5_rightSidePlaylist_volume_btn.addClass('VolumeButtonMute');
				};
			};
			
			vp2_html5_rightSidePlaylist_volume_btn.click(muteVolume);
			
			vp2_html5_rightSidePlaylist_Video.removeAttr('controls');
			
			
			
			
				
			
		});
	};

	//
	// plugin skins
	//
	$.fn.vp2_html5_rightSidePlaylist_Video.skins = {		
	};

})(jQuery);